<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPageAdmin.master" AutoEventWireup="true" CodeFile="List_album.aspx.cs" Inherits="Admin_List_album" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
        .style8
        {
            width: 279px;
        }
        .style10
        {
            width: 279px;
            text-align: right;
        }
        .style11
        {
            font-weight: bold;
            color: #66CCFF;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table class="style7">
        <tr>
            <td colspan="2" style="text-align: center">
                <asp:Label ID="Label1" runat="server" 
                    style="font-size: xx-large; color: #CC9900; font-weight: 700" Text="Album"></asp:Label>
            </td>
        </tr>
        <tr>
            <td class="style8">
                &nbsp;</td>
            <td style="text-align: left">
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                    CellPadding="4" DataKeyNames="albumId" DataSourceID="SqlDataSource1" 
                    ForeColor="#333333" GridLines="None" 
                    onselectedindexchanged="GridView1_SelectedIndexChanged">
                    <RowStyle BackColor="#EFF3FB" />
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="albumId" HeaderText="ID" InsertVisible="False" 
                            ReadOnly="True" SortExpression="albumId" />
                        <asp:BoundField DataField="albumName" HeaderText="Name" 
                            SortExpression="albumName" />
                        <asp:BoundField DataField="albumDescription" HeaderText="Description" 
                            SortExpression="albumDescription" />
                        <asp:BoundField DataField="createdDate" HeaderText="Created Date" 
                            SortExpression="createdDate" />
                        <asp:BoundField DataField="creatorId" HeaderText="Creator Id" 
                            SortExpression="creatorId" />
                    </Columns>
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <EditRowStyle BackColor="#2461BF" />
                    <AlternatingRowStyle BackColor="White" />
                </asp:GridView>
                </td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center">
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                    DeleteCommand="DELETE FROM [tblAlbum] WHERE [albumId] = @albumId" 
                    InsertCommand="INSERT INTO [tblAlbum] ([albumName], [albumDescription], [createdDate], [creatorId]) VALUES (@albumName, @albumDescription, @createdDate, @creatorId)" 
                    SelectCommand="SELECT * FROM [tblAlbum]" 
                    
                    UpdateCommand="UPDATE [tblAlbum] SET [albumName] = @albumName, [albumDescription] = @albumDescription, [createdDate] = @createdDate, [creatorId] = @creatorId WHERE [albumId] = @albumId">
                    <DeleteParameters>
                        <asp:ControlParameter ControlID="txtID" Name="albumId" PropertyName="Text" 
                            Type="Int32" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:ControlParameter ControlID="txtAlbum" Name="albumName" PropertyName="Text" 
                            Type="String" />
                        <asp:ControlParameter ControlID="txtDescription" Name="albumDescription" 
                            PropertyName="Text" Type="String" />
                        <asp:ControlParameter ControlID="cldDate" Name="createdDate" 
                            PropertyName="SelectedDate" Type="DateTime" />
                        <asp:ControlParameter ControlID="ddlID" Name="creatorId" 
                            PropertyName="SelectedValue" Type="Int32" />
                        <asp:ControlParameter Name="albumId" Type="Int32" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:Parameter Name="albumName" Type="String" />
                        <asp:Parameter Name="albumDescription" Type="String" />
                        <asp:Parameter Name="createdDate" Type="DateTime" />
                        <asp:Parameter Name="creatorId" Type="Int32" />
                    </InsertParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td class="style8">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center">
                <asp:Button ID="Button1" runat="server" Text="Add" onclick="Button1_Click" />
&nbsp;
                <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Edit" />
&nbsp;
                <asp:Button ID="Button3" runat="server" Text="Delete" onclick="Button3_Click" />
            </td>
        </tr>
        <tr>
            <td class="style8">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center">
                <asp:Label ID="lblEdit" runat="server" 
                    style="font-size: xx-large; font-weight: 700; color: #CC9900" Text="Edit" 
                    Visible="False"></asp:Label>
            </td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style10">
                <asp:Label ID="Label7" runat="server" CssClass="style11" Text="Album ID" 
                    Visible="False"></asp:Label>
            </td>
            <td>
&nbsp;&nbsp;&nbsp;
                <asp:TextBox ID="txtID" runat="server" Visible="False"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style10">
                <asp:Label ID="Label3" runat="server" CssClass="style11" Text="Album name" 
                    Visible="False"></asp:Label>
            </td>
            <td>
&nbsp;&nbsp;
                <asp:TextBox ID="txtAlbum" runat="server" Visible="False"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style10">
                <asp:Label ID="Label5" runat="server" CssClass="style11" Text="Description" 
                    Visible="False"></asp:Label>
            </td>
            <td>
&nbsp;&nbsp;
                <asp:TextBox ID="txtDescription" runat="server" Visible="False"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style10" valign="top">
                <asp:Label ID="Label4" runat="server" CssClass="style11" Text="Created date" 
                    Visible="False"></asp:Label>
            </td>
            <td>
&nbsp;&nbsp;
                <asp:Calendar ID="cldDate" runat="server" Visible="False"></asp:Calendar>
            </td>
        </tr>
        <tr>
            <td class="style10">
                <asp:Label ID="Label6" runat="server" CssClass="style11" Text="Created ID" 
                    Visible="False"></asp:Label>
            </td>
            <td>
&nbsp;&nbsp;
                <asp:DropDownList ID="ddlID" runat="server" Visible="False">
                    <asp:ListItem></asp:ListItem>
                    <asp:ListItem Value="1">Administartor</asp:ListItem>
                    <asp:ListItem Value="2">Staff</asp:ListItem>
                    <asp:ListItem Value="4">Uploader</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="style10" valign="top">
                &nbsp;</td>
            <td>
                <asp:Button ID="Button4" runat="server" onclick="Button4_Click" Text="Edit" 
                    Visible="False" />
            </td>
        </tr>
    </table>
</asp:Content>

